# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=ois

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3
_oisver=${pkgver/./-}
pkgrel=2
pkgdesc="Object Oriented Input System (mingw-w64)"
arch=('any')
url="http://sourceforge.net/projects/wgois"
license=('custom:zlib/libpng')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('strip' '!libtool' 'staticlibs')
makedepends=('autoconf' 'automake' 'libtool' "${MINGW_PACKAGE_PREFIX}-gcc")
source=("http://downloads.sourceforge.net/project/wgois/Source%20Release/${pkgver}/ois_v${_oisver}.tar.gz"
        "gcc47.patch"
        "configure.patch"
        "demos.patch"
        "win32joystick.patch"
        "win32forcefeedback.patch"
        "win32keyboard.patch"
        "win32mouse.patch"
        "win32prereqs.patch")
md5sums=('9697fead17eac6025151cd2e1fca1518'
         '1b543abeebc61ec87b33ae89158117ff'
         '7d9735229ba47c08a9a4ae2173e7dfa1'
         '07d700c608e2b1b66486e6f2b800be4a'
         '58f85b56b08a504539f3f5084c632bf1'
         '96afb64dafe6c1fa2662cb8191aa6ec1'
         '2b374c67ca790f0fb2095ae99c84ca33'
         '4d46a336492e5a0b8265b841d9337eef'
         '8ca77a78e70776976fd7e906759cab59')

prepare() {
  cd ${srcdir}/ois-v${_oisver}

  patch -Nbp1 < ${srcdir}/gcc47.patch
  patch -Nbp1 < ${srcdir}/configure.patch
  patch -Nbp1 < ${srcdir}/demos.patch
  patch -Nbp1 < ${srcdir}/win32joystick.patch
  patch -Nbp1 < ${srcdir}/win32forcefeedback.patch
  #patch -Nbp1 < ${srcdir}/win32keyboard.patch
  patch -Nbp1 < ${srcdir}/win32mouse.patch
  patch -Nbp1 < ${srcdir}/win32prereqs.patch

  libtoolize --copy --force
  aclocal $ACLOCAL_FLAGS
  autoheader
  automake --include-deps --add-missing --foreign --copy
  autoconf 
}

build() {
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  
  ${srcdir}/ois-v${_oisver}/configure \
     --prefix=${MINGW_PREFIX} \
     --build=${MINGW_CHOST} \
     --host=${MINGW_CHOST} \
     --enable-shared=yes \
     --enable-static=yes
  make
}

package() {
    cd ${srcdir}/build-${MINGW_CHOST}
    make DESTDIR=${pkgdir} install
}
